<?php

namespace common\validate;


class Plan extends BaseValidate
{
    // 验证规则
    protected $rule = [];


    // Fields 验证场景定义
    public function sceneFields()
    {
        return $this;
    }

    // Find 验证场景定义
    public function sceneFind()
    {
        return $this->append('param', 'require')
            ->append('param.filter', 'array');
    }

    // Select 验证场景定义
    public function sceneSelect()
    {
        return $this->append('param', 'require')
            ->append('param.filter', 'array')
            ->append('param.page', 'array');
    }

    // Save 验证场景定义
    public function sceneSave()
    {
        return $this
            ->append('data.project_id', 'require')
            ->append('data.start_time', 'require|date')
            ->append('data.end_time', 'require|date')
            ->append('data.type', 'require');
    }

    // Delete 验证场景定义
    public function sceneDelete()
    {
        return $this->append('param.filter', 'require');
    }

    // SaveBatchWrapper 验证场景定义
    public function sceneSaveBatchWrapper()
    {
        return $this->append('data.project', 'require')
            ->append('data.tasks', 'require')
            ->append('data.project.id', 'require')
//            ->append('data.project.start_time', 'require')
            ->append('data.project.end_time', 'require|date');
    }

    // Save 验证场景定义
    public function sceneSaveBatch()
    {
        return $this->append('step_category_id', 'require')
            ->append('project_id', 'require')
            ->append('start_time', 'require|date')
            ->append('end_time', 'require|date');
    }

    // GetEpisodePlan 验证场景定义
    public function sceneGetEpisodePlan()
    {
        return $this->append("param.filter.project_id", "require");
    }

    // GetEpisodeStepCategoryPlan 验证场景定义
    public function sceneGetEpisodeStepCategoryPlan()
    {
        return $this
            ->append("param.filter.entity_id", "require|integer|min:1")
            ->append("param.filter.project_id", "require|integer|min:1");
    }

    // GetEpisodesStepCategoryTree 验证场景定义
    public function sceneGetEpisodesStepCategoryTree()
    {
        return $this->append("param.filter.project_id", "require|integer|min:1");
    }

    // GetEntityPlan 验证场景定义
    public function sceneGetEntityPlan()
    {
        return $this->append("param.filter.project_id", "require|integer")
            ->append("param.filter.code", "require")
            ->append("param.filter.episode_id", "require")
            ->append("param.filter.module_code", "array");
    }

    // FindPlan 验证场景定义
    public function sceneFindPlan()
    {
        return $this->append("param.filter.project_id", "require|integer")
            ->append("param.filter.entity_id", "require")
            ->append("param.filter.type", "require");
    }


    // Update 验证场景定义
    public function sceneUpdate()
    {
        return $this
            ->append("data", "require")
            ->append("data.id", "require|integer|min:1");
    }

    // CalculateCapacity 验证场景定义
    public function sceneCalculateCapacity()
    {
        return $this
            ->append("param.filter.project_id", "require")
            ->append("param.filter.episode_id", "integer")
            ->append("param.filter.step_category_id", "integer");
    }

    public function sceneCreateGroup()
    {
        return $this
            ->append("param.filter.project_id", "require")
            ->append("param.filter.type", "require")
            ->append("param.filter.entity_id", "require");
    }

    public function sceneDeleteGroup()
    {
        return $this
            ->append("param.filter", "require");
    }

    public function sceneUpdateGroup()
    {
        return $this
            ->append("param.filter", "require")
            ->append("data", "require");
    }

    // getFixedEpisodeStepCategoryPlan 验证场景定义
    public function sceneGetFixedEpisodeStepCategoryPlan()
    {
        return $this->append('param.filter.project_id', 'require|integer')
            ->append('param.filter.step_category_id', 'require|integer');
    }

    public function sceneGetProjectPlanList()
    {
        return $this->append('param.filter.project_id', 'require|integer')
            ->append('param.filter.entity_id', 'require|integer')
            ->append('param.filter.step_category_id', 'require|integer');
    }

    public function sceneGetPlanProjectEpisodeCount()
    {
        return $this->append('param.filter.project_id', 'require|integer')
            ->append('param.filter.step_category_id', 'require|integer');
    }

    public function sceneGetStepCategoryPlanProjectList()
    {
        return $this->append('param.filter.step_category_id', 'require|integer');
    }

    public function sceneGetMultiProjectPlanList()
    {
        return $this->append('param.filter.month', 'require|array');
    }

    public function sceneAddStepCategoryPlan()
    {
        return $this->append('plan', 'require|array')
            ->append('plan.entity_id', 'integer')
            ->append('plan.type', 'in:step_category,to_do,milestone,meeting,review,custom')
            ->append('plan.scope', 'require|in:single,global')
            ->append('plan.step_category_id', 'integer')
            ->append('plan.project_id', 'integer')
            ->append('task', 'requireIf:plan.type,to_do')
            ->append('task.description', 'max:1000')
            ->append('task.step_type', 'requireIf:plan.type,to_do')
            ->append('executor', 'array');
    }

    public function sceneUpdateStepCategoryPlan()
    {
        return $this->append('plan.id', 'require');
    }

    public function sceneGetStepCategoryPlanDetail()
    {
        return $this->append('param.filter', 'require');
    }

    public function sceneRemoveToDoPlan()
    {
        return $this->append('param.filter', 'require');
    }

    public function sceneBatchUpdateStepCategoryPlan()
    {
        return $this->append('data', 'require');
    }

    public function sceneBatchUpdateStepCategoryPlanItem()
    {
        return $this->append('plan.id', 'require')
            ->append('plan.entity_id', 'integer')
            ->append('plan.type', 'in:step_category,to_do')
            ->append('plan.step_category_id', 'integer')
            ->append('plan.project_id', 'integer')
            ->append('task', 'requireIf:plan.type,to_do')
            ->append('task.description', 'max:256')
            ->append('task.step_type', 'requireIf:plan.type,to_do')
            ->append('executor', 'array');
    }

    public function sceneGetPlanOneProjectFind()
    {
        return $this->append('param.filter.id', 'require|integer');
    }

    public function sceneBatchAddStepCategoryPlanItem()
    {
        return $this
            ->append('plan.entity_id', 'require|integer')
            ->append('plan.type', 'require|in:step_category,to_do')
            ->append('plan.step_category_id', 'require|integer')
            ->append('plan.project_id', 'require|integer');
    }

    public function sceneGetPlanMultiProject()
    {
        return $this->append('param.filter.step_category_id', 'require|integer')
            ->append('param.filter.start_time', 'date')
            ->append('param.filter.end_time', 'date');
    }

    public function sceneGetScheduleInfoEntityList()
    {
        return $this->append('param.filter.step_category_id', 'require|integer')
            ->append('param.filter.month_time', 'date')
            ->append('param.filter.project_id', 'integer')
            ->append('param.filter.task_status', 'require|in:not_started,processing,completed,overdue')
            ->append('param.filter.status_filter', 'in:expired,unassigned,executor_other,executor_idling,in_progress,remake,final,not_started,processing')
            ->append('param.filter.department_id', 'array')
            ->append('param.filter.executor', 'array')
            ->append('param.filter.executor_tenant_id', 'array');
    }

    public function sceneGetScheduleInfoTaskList()
    {
        return $this->append('param.filter.step_category_id', 'require|integer')
            ->append('param.filter.month_time', 'date')
            ->append('param.filter.entity_id', 'integer')
            ->append('param.filter.task_status', 'require|in:not_started,processing,completed,overdue')
            ->append('param.filter.status_filter', 'in:expired,unassigned,executor_other,executor_idling,in_progress,remake,final,not_started,processing')
            ->append('param.filter.department_id', 'array')
            ->append('param.filter.executor', 'array')
            ->append('param.filter.executor_tenant_id', 'array');
    }

    public function scenePlanSpecifyEpisodeCopy()
    {
        return $this->append('param.filter.plan_ids', 'require|array')
            ->append('param.filter.episode_id', 'require|integer');
    }

    public function sceneGetValidatePlanResult()
    {
        return $this->append('param.filter.plan_ids', 'require|array')
            ->append('param.filter.episode_id', 'require|integer');
    }

    public function sceneCreatePlanConfirmation()
    {
        return $this->append('data.user_id', 'require')
            ->append('data.plan_id', 'require')
            ->append('data.confirm_end_time', 'require|gt:0');
    }

    public function sceneGetPlanConfirmList()
    {
        return $this->append('param.filter', 'require');
    }

    public function sceneBatchUpdatePlanConfirm()
    {
        return $this->append('data.plan_ids', 'require|array')
            ->append('data.project_id', 'require');
    }

    public function sceneOriginalPlanNodeList()
    {
        return $this
            ->append('param.project_id', 'require|integer')
            ->append('param.start_time', 'require|integer')
            ->append('param.end_time', 'require|integer');
    }

    public function sceneAddPlanLock()
    {
        return $this
            ->append('param.plan_id', 'require');
    }

    public function sceneCancelPlanLock()
    {
        return $this
            ->append('param.plan_id', 'require');
    }


}
